#!/usr/bin/make -f
ARCH=$(shell dpkg-architecture -qDEB_BUILD_ARCH)

ifeq ($(ARCH),$(filter $(ARCH),powerpc mips mipsel))
CC=/usr/bin/clang
CXX=/usr/bin/clang++
else
CC=/usr/bin/gcc
CXX=/usr/bin/g++
endif

OCTAVE_INCLUDE_DIR=$(shell octave-config -p OCTINCLUDEDIR)
CMAKE_INCLUDE_PATH=$(OCTAVE_INCLUDE_DIR)

C_INCLUDE_PATH=$(OCTAVE_INCLUDE_DIR)
CPLUS_INCLUDE_PATH=$(OCTAVE_INCLUDE_DIR)
export C_INCLUDE_PATH
export CPLUS_INCLUDE_PATH

ifeq ($(ARCH),$(filter $(ARCH),i386 hurd-i386 kfreebsd-i386))
	DISABLE_SSE="-DDISABLE_SSE=ON"
endif


all:
	echo ${CXX}

%:
	dh $@ --buildsystem=cmake

override_dh_auto_configure:
	ln -s /usr/include/shogun shogun
	dh_auto_configure -- -DENABLE_CCACHE=FALSE -DCMAKE_SKIP_RPATH=TRUE \
		-DBUILD_EXAMPLES=OFF -DUSE_SVMLIGHT=OFF -DOctaveStatic=ON -DOctaveModular=ON \
		-DCMAKE_C_COMPILER=$(CC) -DCMAKE_CXX_COMPILER=$(CXX) -DSWIG_EXECUTABLE=/usr/bin/swig3.0 \
		$(DISABLE_SSE) \
		-DCMAKE_CXX_FLAGS="-I$(OCTAVE_INCLUDE_DIR)" -DCMAKE_C_FLAGS="-I$(OCTAVE_INCLUDE_DIR)"

override_dh_install:
	$(MAKE) -C doc examples
	dh_install

override_dh_strip:
	dh_strip --dbg-package=octave-shogun-dbg
